package com.qingzhu.dao.impl;

import com.qingzhu.dao.BrandDao;
import com.qingzhu.pojo.Brand;
import com.qingzhu.util.CreateSqlSessionFactory;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class BrandDaoImpl implements BrandDao {

    @Override
    public List<Brand> findBrandAll() {
        try(SqlSession sqlSession = CreateSqlSessionFactory.getFactory().openSession(true)){
            BrandDao mapper = sqlSession.getMapper(BrandDao.class);
            return mapper.findBrandAll();
        }
    }

    @Override
    public Brand findByName(String name) {
        try(SqlSession sqlSession = CreateSqlSessionFactory.getFactory().openSession(true)){
            BrandDao mapper = sqlSession.getMapper(BrandDao.class);
            return mapper.findByName(name);
        }
    }
}
